﻿using APP.HELPER.Data.Helper;
using DevExpress.XtraEditors;
using System; using Extra.ERP;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Windows.Forms; using Common;

namespace HRM.CORE
{
    

    public class HRM_EMPLOYEE_ALLOWANCE
    {
        private string m_AllowanceCode;
        private string m_EmployeeCode;
        private double m_IncomeTaxValue;
        private bool m_IsByWorkDay;
        private decimal m_Money;

        public HRM_EMPLOYEE_ALLOWANCE()
        {
            this.m_EmployeeCode = "";
            this.m_AllowanceCode = "";
            this.m_Money = 0M;
            this.m_IsByWorkDay = false;
            this.m_IncomeTaxValue = 0.0;
        }

        public HRM_EMPLOYEE_ALLOWANCE(string EmployeeCode, string AllowanceCode, decimal Money, bool IsByWorkDay, double IncomeTaxValue)
        {
            this.m_EmployeeCode = EmployeeCode;
            this.m_AllowanceCode = AllowanceCode;
            this.m_Money = Money;
            this.m_IsByWorkDay = IsByWorkDay;
            this.m_IncomeTaxValue = IncomeTaxValue;
        }

        public string Delete()
        {
            string[] myParams = new string[] { "@EmployeeCode" };
            object[] myValues = new object[] { this.EmployeeCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_EMPLOYEE_ALLOWANCE_Delete", myParams, myValues);
        }

        public string Delete(string EmployeeCode)
        {
            string[] myParams = new string[] { "@EmployeeCode" };
            object[] myValues = new object[] { EmployeeCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_EMPLOYEE_ALLOWANCE_Delete", myParams, myValues);
        }

        public string Delete(SqlTransaction myTransaction, string EmployeeCode)
        {
            string[] myParams = new string[] { "@EmployeeCode" };
            object[] myValues = new object[] { EmployeeCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_EMPLOYEE_ALLOWANCE_Delete", myParams, myValues);
        }

        public string Delete(SqlConnection myConnection, string EmployeeCode, string AllowanceCode)
        {
            string[] myParams = new string[] { "@EmployeeCode" };
            object[] myValues = new object[] { EmployeeCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_EMPLOYEE_ALLOWANCE_Delete", myParams, myValues);
        }

        private void DispError(object sender, SqlHelperException e)
        {
            XtraMessageBox.Show(e.Message, "Th\x00f4ng B\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
        }

        public bool Exist(string EmployeeCode, string AllowanceCode)
        {
            bool hasRows = false;
            string[] myParams = new string[] { "@EmployeeCode", "@AllowanceCode" };
            object[] myValues = new object[] { EmployeeCode, AllowanceCode };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_EMPLOYEE_ALLOWANCE_Get", myParams, myValues);
            if (reader != null)
            {
                hasRows = reader.HasRows;
                reader.Close();
                helper.Close();
                reader = null;
            }
            return hasRows;
        }

        public string Get(string EmployeeCode, string AllowanceCode)
        {
            string str = "";
            string[] myParams = new string[] { "@EmployeeCode", "@AllowanceCode" };
            object[] myValues = new object[] { EmployeeCode, AllowanceCode };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_EMPLOYEE_ALLOWANCE_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_AllowanceCode = Convert.ToString(reader["AllowanceCode"]);
                    this.m_Money = Convert.ToDecimal(reader["Money"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlConnection myConnection, string EmployeeCode, string AllowanceCode)
        {
            string str = "";
            string[] myParams = new string[] { "@EmployeeCode", "@AllowanceCode" };
            object[] myValues = new object[] { EmployeeCode, AllowanceCode };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myConnection, "HRM_EMPLOYEE_ALLOWANCE_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_AllowanceCode = Convert.ToString(reader["AllowanceCode"]);
                    this.m_Money = Convert.ToDecimal(reader["Money"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlTransaction myTransaction, string EmployeeCode, string AllowanceCode)
        {
            string str = "";
            string[] myParams = new string[] { "@EmployeeCode", "@AllowanceCode" };
            object[] myValues = new object[] { EmployeeCode, AllowanceCode };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myTransaction, "HRM_EMPLOYEE_ALLOWANCE_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_AllowanceCode = Convert.ToString(reader["AllowanceCode"]);
                    this.m_Money = Convert.ToDecimal(reader["Money"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public DataTable GetList(string EmployeeCode)
        {
            string[] myParams = new string[] { "@EmployeeCode" };
            object[] myValues = new object[] { EmployeeCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_EMPLOYEE_ALLOWANCE_GetList", myParams, myValues);
        }

        public string Insert()
        {
            string[] myParams = new string[] { "@EmployeeCode", "@AllowanceCode", "@Money", "@IsByWorkDay", "@IncomeTaxValue" };
            object[] myValues = new object[] { this.m_EmployeeCode, this.m_AllowanceCode, this.m_Money, this.m_IsByWorkDay, this.m_IncomeTaxValue };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_EMPLOYEE_ALLOWANCE_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction)
        {
            string[] myParams = new string[] { "@EmployeeCode", "@AllowanceCode", "@Money", "@IsByWorkDay", "@IncomeTaxValue" };
            object[] myValues = new object[] { this.m_EmployeeCode, this.m_AllowanceCode, this.m_Money, this.m_IsByWorkDay, this.m_IncomeTaxValue };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_EMPLOYEE_ALLOWANCE_Insert", myParams, myValues);
        }

        public string Insert(string EmployeeCode, string AllowanceCode, decimal Money, bool IsByWorkDay, double IncomeTaxValue)
        {
            string[] myParams = new string[] { "@EmployeeCode", "@AllowanceCode", "@Money", "@IsByWorkDay", "@IncomeTaxValue" };
            object[] myValues = new object[] { EmployeeCode, AllowanceCode, Money, IsByWorkDay, IncomeTaxValue };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_EMPLOYEE_ALLOWANCE_Insert", myParams, myValues);
        }

        public string Insert(SqlConnection myConnection, string EmployeeCode, string AllowanceCode, decimal Money, bool IsByWorkDay, double IncomeTaxValue)
        {
            string[] myParams = new string[] { "@EmployeeCode", "@AllowanceCode", "@Money", "@IsByWorkDay", "@IncomeTaxValue" };
            object[] myValues = new object[] { EmployeeCode, AllowanceCode, Money, IsByWorkDay, IncomeTaxValue };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_EMPLOYEE_ALLOWANCE_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction, string EmployeeCode, string AllowanceCode, decimal Money, bool IsByWorkDay, double IncomeTaxValue)
        {
            string[] myParams = new string[] { "@EmployeeCode", "@AllowanceCode", "@Money", "@IsByWorkDay", "@IncomeTaxValue" };
            object[] myValues = new object[] { EmployeeCode, AllowanceCode, Money, IsByWorkDay, IncomeTaxValue };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_EMPLOYEE_ALLOWANCE_Insert", myParams, myValues);
        }

        public string Update()
        {
            string[] myParams = new string[] { "@EmployeeCode", "@AllowanceCode", "@Money", "@IsByWorkDay", "@IncomeTaxValue" };
            object[] myValues = new object[] { this.m_EmployeeCode, this.m_AllowanceCode, this.m_Money, this.m_IsByWorkDay, this.m_IncomeTaxValue };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_EMPLOYEE_ALLOWANCE_Update", myParams, myValues);
        }

        public string Update(SqlTransaction myTransaction)
        {
            string[] myParams = new string[] { "@EmployeeCode", "@AllowanceCode", "@Money", "@IsByWorkDay", "@IncomeTaxValue" };
            object[] myValues = new object[] { this.m_EmployeeCode, this.m_AllowanceCode, this.m_Money, this.m_IsByWorkDay, this.m_IncomeTaxValue };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_EMPLOYEE_ALLOWANCE_Update", myParams, myValues);
        }

        public string Update(string EmployeeCode, string AllowanceCode, decimal Money, bool IsByWorkDay, double IncomeTaxValue)
        {
            string[] myParams = new string[] { "@EmployeeCode", "@AllowanceCode", "@Money", "@IsByWorkDay", "@IncomeTaxValue" };
            object[] myValues = new object[] { EmployeeCode, AllowanceCode, Money, IsByWorkDay, IncomeTaxValue };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_EMPLOYEE_ALLOWANCE_Update", myParams, myValues);
        }

        public string Update(SqlConnection myConnection, string EmployeeCode, string AllowanceCode, decimal Money, bool IsByWorkDay, double IncomeTaxValue)
        {
            string[] myParams = new string[] { "@EmployeeCode", "@AllowanceCode", "@Money", "@IsByWorkDay", "@IncomeTaxValue" };
            object[] myValues = new object[] { EmployeeCode, AllowanceCode, Money, IsByWorkDay, IncomeTaxValue };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_EMPLOYEE_ALLOWANCE_Update", myParams, myValues);
        }

        public string Update(SqlTransaction myTransaction, string EmployeeCode, string AllowanceCode, decimal Money, bool IsByWorkDay, double IncomeTaxValue)
        {
            string[] myParams = new string[] { "@EmployeeCode", "@AllowanceCode", "@Money", "@IsByWorkDay", "@IncomeTaxValue" };
            object[] myValues = new object[] { EmployeeCode, AllowanceCode, Money, IsByWorkDay, IncomeTaxValue };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_EMPLOYEE_ALLOWANCE_Update", myParams, myValues);
        }

        [Category("Primary Key"), DisplayName("AllowanceCode")]
        public string AllowanceCode
        {
            get
            {
                return this.m_AllowanceCode;
            }
            set
            {
                this.m_AllowanceCode = value;
            }
        }

        [Category("Primary Key"), DisplayName("EmployeeCode")]
        public string EmployeeCode
        {
            get
            {
                return this.m_EmployeeCode;
            }
            set
            {
                this.m_EmployeeCode = value;
            }
        }

        [Category("Column"), DisplayName("IncomeTaxValue")]
        public double IncomeTaxValue
        {
            get
            {
                return this.m_IncomeTaxValue;
            }
            set
            {
                this.m_IncomeTaxValue = value;
            }
        }

        [Category("Column"), DisplayName("IsByWorkDay")]
        public bool IsByWorkDay
        {
            get
            {
                return this.m_IsByWorkDay;
            }
            set
            {
                this.m_IsByWorkDay = value;
            }
        }

        [DisplayName("Money"), Category("Column")]
        public decimal Money
        {
            get
            {
                return this.m_Money;
            }
            set
            {
                this.m_Money = value;
            }
        }
    }
}

